<template>
	<view>
		<block v-for="itemInfo in itemList">
			<index-item :itemInfo="itemInfo"></index-item>
		</block>

	</view>
</template>

<script>
	import indexItem from "@/components/index/index-item.vue";
	export default {
		components: {
			indexItem
		},
		data() {
			return {
				type: 0, // 1 星球精选  0 热门话题
				itemList: []
			};
		},
		onLoad(opt) {

			this.type = opt.type;

			uni.showLoading({
				title: 'loading...',
				mask: true
			})

			this.initData()
		},
		methods: {
			initData() {
				let {
					type,
					itemList
				} = this;
				let dataList = [];
				if (type) {
					dataList = uni.getStorageSync('recommendsData')
				} else {
					dataList = uni.getStorageSync('newestData')
				}
				// 獲取當前數據列表
				this.itemList = dataList;
				uni.hideLoading()
				uni.setNavigationBarTitle({
					title: type == 1 ? '星球精选' : '热门话题'
				});
			}
		}
	}
</script>

<style lang="scss">

</style>
